package com.jorado.etl.service.evaluate;

import com.jorado.core.utility.IOUtils;
import com.jorado.json.JsonUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Test {


    RecommendEvaluate.RecallFun jobTypeFun = (N, user, jobs) -> {
        return 0;
    };


    public void getUserData(List<DataModel> datas, List<UserInfo> users, Map<String, List<JobInfo>> userJobs) {
        for (DataModel model : datas) {
            if (model.getSubMajorId().equals("9999"))
                continue;
            if (!userJobs.containsKey(model.getUserId())) {
                users.add(new UserInfo(model.getUserId(), model.getSex(), model.getCityId(), model.getSchoolId(), model.getSubMajorId()));
                userJobs.put(model.getUserId(), new ArrayList<>());
            }
            userJobs.get(model.getUserId()).add(new JobInfo(model.getJobId(), model.getJobType(), model.getJobCityId()));
        }
    }

    public void test() {

        RecommendEvaluate recommendEvaluate = new RecommendEvaluate();

        List<DataModel> datas = new ArrayList<>();
        List<UserInfo> users = new ArrayList<>();
        Map<String, List<JobInfo>> userJobs = new HashMap<>();

        List<String> lines = IOUtils.readLines("d:\\apply.txt", true);

        for (String line : lines) {
            DataModel model = new DataModel(line);
            datas.add(model);
        }
        getUserData(datas, users, userJobs);

        Map<String, Double> multipleN3 = recommendEvaluate.multiple(3, users, userJobs, jobTypeFun);
        Map<String, Double> multipleN4 = recommendEvaluate.multiple(5, users, userJobs, jobTypeFun);

        System.out.print(JsonUtils.toJson(multipleN3));
        System.out.print(JsonUtils.toJson(multipleN4));
    }
}
